<!DOCTYPE html>
<html lang="zh-cn"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head th:replace="common::head"></head>
<body>
<div th:replace="common::top"></div>
<br/>
<h2>发货</h2>
<br/>

<div style="text-align:left; margin-left:55px;">
    <li th:text="'编码: ' + ${order.id}"></li>
    <li><span>开单: </span><span th:text="${order.confirm} ? '是':'否'"></span></li>
    <li><span>发货: </span><span th:text="${order.send} ? '已发':'未发'"></span></li>
    <li th:text="'创建时间: ' + ${order.createTime}"></li>
    <input type="number" name="id" th:value="${order.id}" hidden>
</div>

<table>
    <tr>
        <td colspan="6" th:text="${corporate}"></td>
    </tr>
    <tr>
        <td colspan="6">发货清单</td>
    </tr>
    <tr>
        <td>客户名称</td>
        <td colspan="2" th:text="${order.customName}"></td>
        <td>日期</td>
        <td colspan="2" th:text="${#dates.format(order.createTime,'yyyy-MM-dd HH:mm')}"></td>
    </tr>
    <tr>
        <td>序号</td>
        <td>产品</td>
        <td>数量</td>
        <td>实数</td>
        <td>备齐</td>
        <td>备注</td>
    </tr>
    <tr th:each="item : ${batchList}">
        <td th:text="${itemStat.index+1}"></td>
        <td th:text="${item.productName}"></td>
        <td th:text="${item.number}"></td>
        <td th:text="${item.producedNumber}"></td>
        <td th:text="${item.gap}==0 ? '√':'×' "></td>
        <td th:text="${item.remark}"></td>
    </tr>
</table>
<form th:if="!${order.send}" th:action="@{send}" method="post">
    <input type="number" name="id" th:value="${order.id}" hidden>
    <input type="submit" value="确认发货" style="width:220px;">
</form>
<p>
    <a href="javascript:history.back(-1);">返回上一页</a>
    <a href="../index.html" th:href="@{/index.html}">主页</a>
</p>

<script>
    $("form").submit(function(e){
        e.preventDefault();

        $.ajax({
            type: $(e.target).attr("method"),
            url: $(e.target).attr("action"),
            data: $(e.target).serialize(),
            success: function(response){
                window.location.reload();
            },
            error: function(response){
                alert("提交失败");
            }
        });
    });
</script>
</body>
</html>